import React from 'react'
import * as PropTypes from 'prop-types';
import ReactEcharts from 'echarts-for-react';
import echartsConfig from 'utils/echartsConfig'
import Tools from 'utils/tools'

class Common extends React.Component {
    static defaultProps = {
        dataSource: [],
        columns: {},
    }

    // {
    //     yAxis: [{ name: '百万' }, { name: '公里' }],
    //     xAxis: { filed: 'YEAR' }, // 图表类型
    //     items: [
    //       { name: '供水人口总数', filed: 'GSRKZS', type: 'line', style: 'areaStyle' },
    //       { name: '管网长度', filed: 'GWCD', type: 'line', yAxisIndex: 1 }
    //     ],
    //     color: ['50,177,108', '0,244,255']
    //   },
      
    render(){
        const { dataSource, columns, color, other, style = {height: '265px'} } = this.props;
        const Data = Tools.formatSQLData(dataSource, columns);
        const Options = echartsConfig.commonEChartsOptions(Data, color, other)
        return (
            <ReactEcharts
                option={Options}
                notMerge={true}
                lazyUpdate={true}
                style={style}
            />
        )
    }
}

Common.propTypes = {
    dataSource: PropTypes.array,
    columns: PropTypes.object,
}
export default Common
